/**
 * DOM 操作封装
 */
function ready(back) {
    window.addEventListener("DOMContentLoaded", back)
}

function gete(selector) {
    return document.querySelector(selector)
}

function getes(selector) {
    return document.querySelectorAll(selector)
}

function addevent(obj, callback, type = 'click') {
    gete(obj).addEventListener(type, callback)
}


function bMenu(obj) {
    document.body.innerHTML += `
    <footer>
    <ul class="df tcenter f12">
      <li><a href="home.html" class="${obj=='home'?'active':''}"><i class="iconfont icon-home"></i><span>首页</span></a></li>
      <li><a href="sport.html" class="${obj=='sport'?'active':''}"><i class="iconfont icon-ball"></i><span>运动</span></a></li>
      <li><a href="circle.html" class="${obj=='circle'?'active':''}"><i class="iconfont icon-circle"></i><span>圈子</span></a></li>
      <li><a href="my.html" class="${obj=='my'?'active':''}"><i class="iconfont icon-mine"></i><span>我的</span></a></li>
    </ul>
  </footer>
    `
}

function formatDate(val) {
    //基本操作
    // if(val<10){
    //     val='0'+val;
    // }else{
    //     val=val
    // }

    return val < 10 ? '0' + val : val;

}

function upLoadPic(url, key, val, cb) {
    let fd = new FormData();
    fd.append(key, val);
    https.post(url, fd, cb)
}

//处理 小于10的数字为两位格式
function formatDate(val) {
    //基本操作
    // if(val<10){
    //     val='0'+val;
    // }else{
    //     val=val
    // }

    return val < 10 ? '0' + val : val;

}
module.exports = {
    ready,
    gete,
    getes,
    addevent,
    bMenu,
    formatDate,
    upLoadPic
}